/**
 * @author Silas Fontain, Søren Lorentzen, Daniel Nissen
 */

package ordination;

import java.util.ArrayList;
import java.util.Collections;
import java.util.GregorianCalendar;
import java.util.List;

public class PN extends Ordination {
	
	private double antalEnheder;
	private List<GregorianCalendar> ordinationer;
	
	
	public PN(GregorianCalendar startDen, GregorianCalendar slutDen, Laegemiddel laegemiddel, int antalEnheder) {
		super(startDen, slutDen, laegemiddel);
		this.antalEnheder = antalEnheder;
		ordinationer = new ArrayList<GregorianCalendar>();
	}


	
	public boolean dosisGivet(GregorianCalendar givetDen) {
			ordinationer.add(givetDen);
			Collections.sort(ordinationer);
		return true;

	}

	public int getAntalGangeGivet() {
		return ordinationer.size();
	}

	public double getAntalEnheder() {
		return antalEnheder;
	}

	@Override
	public double samletDosis() {
		return antalEnheder * ordinationer.size();
	}

	@Override
	public double doegnDosis() {
		int antalDageMellem = (int)((ordinationer.get(ordinationer.size()-1).getTimeInMillis() - ordinationer.get(0).getTimeInMillis())/(24*60*60*1000))+1;
		return (getAntalGangeGivet() * getAntalEnheder()) / antalDageMellem;
	}

}
